import { request, config } from 'utils'
import * as commonService from "utils/services";
import moment from 'moment';

const { api } = config
const { financialReceipt, salesPaymenter, userTenant } = api

export async function query(params = {}) {
  params.apiBaseUrl = `${financialReceipt}`;
  return commonService.commonQuery(params);
}
export async function create(params) {
  const url = `${financialReceipt}/create`;
  return request({ url: url, method: 'POST', data: params })
}
export async function detail(id) {
  const url = `${financialReceipt}/${id}/detail`;
  return request({ url: url, method: 'GET', data: {} })
}
export async function approve(params = {}) {
  const url = `${financialReceipt}/${params.id}/approve`;
  return request({ url: url, method: 'POST', data: { "remark": params.remark === undefined || null || "" ? "默认内容" : params.remark, "serviceFee": params.serviceFee, "settlementNum": params.settlementNum, "arrivalTime": moment(params.arrivalTime).valueOf() } })
}
export async function deny(params = {}) {
  const url = `${financialReceipt}/${params.id}/deny`;
  return request({ url: url, method: 'POST', data: { "remark": params.remark === undefined || null || "" ? "默认内容" : params.remark, "serviceFee": params.serviceFee, "settlementNum": params.settlementNum } })
}
export async function listPaymenters(params = {}) {
  const url = `${salesPaymenter}/distributor/list`
  return request({ url: url, method: 'POST', data: { ...params } })
}
export async function listDistributors(params = {}) {
  const url = `${salesPaymenter}/distributor/mine`
  return request({ url: url, method: 'GET' })
}
export async function findReceipter(params = {}) {
  const url = `${salesPaymenter}/distributor/receipter`
  return request({ url: url, method: 'POST', data: {} })
}
export async function listByAccount(account) {
  const url = `${financialReceipt}/list/byAccount/${account}`;
  return request({ url: url, method: 'POST', data: {} })
}
export async function listPaymentPattern(account) {
  const url = `${financialReceipt}/listPaymentPattern`;
  return request({ url: url, method: 'GET', data: {} })
}
export async function listRoles() {
  const url = `${userTenant}/roles`;
  return request({ url: url, method: 'POST', data: {} })
}
export async function checkPaymentNum(params) {
  const url = `${financialReceipt}/checkPaymentNum/${params}`;
  return request({ url: url, method: 'GET', data: {} })
}
